#!/bin/bash
# 62 Bit Version
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
host_os=`uname -s | tr "[:upper:]" "[:lower:]"`
SRCDIR=${DIR}/luajit-2.1
ZLIB_VERSION="1.2.11"
NDK=/sdks/mingw-w64/mingw-w64-x86_64


cd $SRCDIR
make clean
NDKP=$NDK/bin/x86_64-w64-mingw32-
make BUILDMODE=static CC="gcc -m64 -O3" CROSS=$NDKP TARGET_SYS=Windows XCFLAGS=-DLUAJIT_ENABLE_GC64


rm -rf ${DIR}/build_lj64
mkdir -p ${DIR}/build_lj64 && cd ${DIR}/build_lj64
cmake -DUSING_LUAJIT=ON -DCMAKE_TOOLCHAIN_FILE=../cmake/windows.toolchain.cmake -G "Unix Makefiles" ../
cd ${DIR}
cmake --build build_lj64 --config Release
mkdir -p ${DIR}/plugin_luajit/Plugins/x86_64
cp ${DIR}/build_lj64/libxlua.dll ${DIR}/plugin_luajit/Plugins/x86_64/tolua.dll